package eecs285.proj4.gui;

//Class: EECS 285
//Project: 
//Due Date: Monday December 6th, 2010

//NOTES: 

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.util.ArrayList;

import static eecs.util.Utility.*;

/**
 * A derived class for actions performed on a Markerboard.
 * 
 * @author Easton Thomas
 * @author Stubbed by Hans Marquard
 */
@SuppressWarnings("serial")
public class Erase extends MAction
{

  // ---------------------------------------------------------------------------

  /**
   * Constructor.
   * 
   * @author Easton Thomas
   * @author Hans Marquard
   */
  public Erase(Point new_point)
  {
    super(TYPE.ERASE);
    setColor(Color.WHITE);
    points = new ArrayList<Point>();
    points.add(new_point);
  }

  // ---------------------------------------------------------------------------

  /**
   * Include an additional Point in the mouse movement.
   * 
   * @author Easton Thomas
   */
  public void add_point(Point new_point)
  {
    points.add(new_point);
  }

  // ---------------------------------------------------------------------------

  /**
   * Implementation of abstract draw method. Draws this type of object.
   * 
   * @param g2
   *          The Graphics object to draw on.
   * @author Easton Thomas
   * @author Stubbed by Hans Marquard
   */
  public void draw(Graphics2D g2)
  {

    g2.setStroke(new BasicStroke(8*stroke, BasicStroke.CAP_ROUND,
        BasicStroke.JOIN_ROUND)); // set line width of Eraser
    g2.setColor(Color.WHITE);

    for (int i = 1; i < points.size(); i++)
    {
      g2.drawLine(points.get(i - 1).x, points.get(i - 1).y, points.get(i).x,
          points.get(i).y);
    }
  }// draw

}// Erase
